package serviceImpl;

import dao.CityMapper;
import dao.CountryMapper;
import entity.City;
import entity.Country;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import service.CountryService;
import util.DaoUtil;

/**
 * ClassName:CountryServiceImpl
 * Package:serviceImpl
 *
 * @date:2021/11/1 9:50 下午
 * @author: Tiangle
 */
public class CountryServiceImpl implements CountryService {
    DaoUtil du = DaoUtil.getDu();


    @Override
    public Country getCountry(String code) {
        SqlSession sqlS = du.getSqlS();
        CountryMapper mapper = sqlS.getMapper(CountryMapper.class);
        Country countryAndCity = mapper.getCountryAndCity(code);
        sqlS.close();
        return countryAndCity;
    }

    @Override
    public City getCity(int id) {
        SqlSession sqlS = du.getSqlS();
        CityMapper mapper = sqlS.getMapper(CityMapper.class);
        City city = mapper.getCity(id);
        sqlS.close();
        return city;
    }
}
